home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 2
/
Deutsche Edition 2.iso
/
mac
/
BILDSCHIRMSCHONER
/
AFTER DARK ADDS
/
Slinkicizer
/
Slinkicizer.p
< prev
Wrap
Text File
|
1991-08-05
|
4KB
|
172 lines
{Slinkicizer.p}
{Some of this code is modeled after the After Dark Module "7.0fo"
In the spirit of sharing please tear this apart and make more modules.
Dan LaSota
Ant Man! }
unit danz;
interface
uses
Quickdraw, Sound, Files, Processes, Packages, Fonts,
Memory, Toolutils, OSUtils, GestaltEqu, GraphicsModuleTypes;
function DoInitialize (var storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
function DoBlank (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
function DoDrawFrame (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
function DoClose (storage: Handle; blankRgn: RgnHandle; params: GMParamBlockPtr): OSErr;
function DoSetup (blankRgn: rgnHandle; message: integer; params: GMParamBlockPtr): OSErr;
implementation
type
theData =
record
theRect: Rect; { Holds the bounding rectangle for the circle. }
x: integer;
y: integer;
dh: integer;
dv: integer;
len: integer;
wid: integer;
shape:integer;
screenRect: Rect;
end;
thePtr = ^theData;
theHandle = ^thePtr;
procedure eraseIT(r:rect;shape:integer);
begin
PenPat(black);
case shape of
1: FrameRect(r);
2: FrameOval(r);
end
end;
function getRect(x,y,length,width:integer): Rect;
var
a,b: integer;
box : rect;
begin
a := length div 2;
b := width div 2;
setRect(box,x-b,y-a,x+b,y+a);
getRect := box
end;
function DoInitialize (var storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
var od: theHandle;
i,j,k: integer;
osAttr: longInt;
begin
storage := NewHandle(sizeof(theData));
if MemError <> noErr then
begin
DoInitialize := MemError;
exit(DoInitialize);
end;
params^.qdGlobalsCopy^.qdRandSeed := TickCount;
od := theHandle(storage);
od^^.wid:=params^.controlValues[0];
od^^.len:=params^.controlValues[1];
od^^.shape:=params^.controlValues[2];
od^^.screenRect:=params^.monitors^.monitorList[0].bounds;
j := od^^.screenRect.right -200;
k := od^^.screenRect.bottom -200;
od^^.theRect:=getRect((abs(random mod k) + 100),(abs(random mod j) + 100),od^^.wid,od^^.len);
od^^.screenRect:=params^.monitors^.monitorList[0].bounds;
od^^.dh:=abs(random mod 10) + 1;
od^^.dv :=abs(random mod 10) + 1;
PenPat(white);
DoInitialize := noErr;
exit(DoInitialize);
end;
function DoBlank (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
begin
{FillRgn(blankRgn, params^.qdGlobalsCopy^.qdBlack);}
DoBlank := noErr;
end;
function DoDrawFrame (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
var od: theHandle; { Handle to the data (coerced from storage). }
r: Rect; { Rectangle of the current monitor. }
i,dx,dy,temp: integer;
begin
od := theHandle(storage);
if od = nil then exit(DoDrawFrame);
dx:= od^^.dh;
dy := od^^.dv;
r:= od^^.theRect;
temp:=od^^.screenRect.right;
if (r.right>temp) then
begin
eraseIT(r,od^^.shape);
OffSetRect(r,temp-r.right,0);
dy:=abs(random mod 10) + 1;
dy:=dy * (-1);
end
else
begin
temp:=od^^.screenRect.left ;
if (r.left<temp) then
begin
eraseIT(r,od^^.shape);
OffSetRect(r,-temp,0);
dy:=abs(random mod 10) + 1;
dy:=dy * (1);
end
end;
temp:=od^^.screenRect.top;
if (r.top<temp) then
begin
eraseIT(r,od^^.shape);
OffSetRect(r,0,temp-r.top-1);
dx:=dx * (-1);
end
else
begin
temp:=od^^.screenRect.bottom ;
if (r.bottom>temp) then
begin
eraseIT(r,od^^.shape);
{ OffSetRect(r,0,r.bottom-temp+1); }
dx:=abs(random mod 10) + 1;
dx:=dx * (-1);
end
end;
PenPat(black);
eraseIT(r,od^^.shape);
OffSetRect(r,dy,dx);
od^^.dh:=dx;
od^^.dv:=dy;
od^^.theRect:=r;
PenPat(white);
case od^^.shape of
1: FrameRect(r);
2: FrameOval(r);
end;
DoDrawFrame := noErr;
end;
function DoClose (storage: Handle; blankRgn: RgnHandle; params: GMParamBlockPtr): OSErr;
begin
if storage <> nil then DisposHandle(storage);
DoClose := noErr;
end;
function DoSetup (blankRgn: rgnHandle; message: integer; params: GMParamBlockPtr): OSErr;
begin
DoSetup := noErr;
end;
end.